﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 引用和值类型
{
    public static class Utils
    {
        //例子测试
        public static void OneBox()
        {
            Int32 v = 5;//创建一个未装箱的值类型变量
            Object o = v;//o引用v的已装箱版本

            v = 123;//将未装箱的值类型修改成123
            Console.WriteLine(v); //123
            v = (Int32)o;//拆箱并将o复制到v
            Console.WriteLine(v);//显示5
            //本次总共进行了一次装箱
        }

        public static void ThreeBoxing()
        {
            Int32 v = 5;
            Object o = v;
            v = 123;
            Console.WriteLine(v + "," + (Int32)o);// 总共有三次装箱
            Console.WriteLine(new object());


        }
    }
}
